package com.pipi.biyesheji.enums;

import com.google.common.collect.Maps;
import lombok.AllArgsConstructor;
import lombok.Getter;

import java.util.Map;
import java.util.Objects;

/**
 * All rights Reserved, Designed By www.maihaoche.com
 *
 * @Package com.pipi.biyesheji.enums
 * @author: 皮皮（pipi@maihaoche.com）
 * @date: 2019/4/17 10:40 PM
 * @Copyright: 2017-2020 www.maihaoche.com Inc. All rights reserved.
 * 注意：本内容仅限于卖好车内部传阅，禁止外泄以及用于其他的商业目
 */
public class AllEnums {

    @AllArgsConstructor
    public enum OrderStatusEnum {
        /**
         * <p> 订单已取消 </p>
         */
        CANCEL(0, "已取消"),
        /**
         * <p> 订单未发货 </p>
         */
        NO_SHIPMENT(1, "未发货"),
        /**
         * <p> 订单已发货 </p>
         */
        SHIPMENT(2, "已发货"),
        /**
         * <p> 已确认未发货 </p>
         */
        CONFIRM(3, "已确认"),
        ;

        @Getter
        private Integer code;

        @Getter
        private String desc;

        public static String getDescByCode(Integer code) {
            if (Objects.isNull(code)) {
                return null;
            }
            OrderStatusEnum[] values = OrderStatusEnum.values();
            for (OrderStatusEnum value : values) {
                if (Objects.equals(value.getCode(), code)) {
                    return value.getDesc();
                }
            }
            return null;
        }
    }


    @AllArgsConstructor
    public enum RoleEnum {
        ADMIN("admin", "管理员"),
        BUSINESS("business", "商家");

        @Getter
        private String name;

        @Getter
        private String description;

        public static String getDescriptionByName(String name) {
            if (Objects.isNull(name)) {
                return null;
            }
            RoleEnum[] values = RoleEnum.values();
            for (RoleEnum value : values) {
                if (Objects.equals(value.getName(), name)) {
                    return value.getDescription();
                }
            }
            return null;
        }
    }

}
